package edu.xkd.slice;

import edu.xkd.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class SecordAbilitySlice extends AbilitySlice {
    Text text02_04=null;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_secord);

        // 获取按钮对象
        Button button02_01 = (Button) this.findComponentById(ResourceTable.Id_button02_01);

        // 跳转到第二个ability里
        button02_01.setClickedListener(this::ClickedListenerButton02_01);

        text02_04= (Text) this.findComponentById(ResourceTable.Id_text02_04);
        text02_04.setClickedListener(this::ClickedListenerText02_04);
        text02_04.setDoubleClickedListener(this::DoubleClickedListenerText02_04);
        text02_04.setTruncationMode(Text.TruncationMode.AUTO_SCROLLING);

    }

    private void DoubleClickedListenerText02_04(Component component) {
        text02_04.stopAutoScrolling();
    }

    private void ClickedListenerText02_04(Component component) {
        text02_04.startAutoScrolling();
    }

    private void ClickedListenerButton02_01(Component component) {
        this.terminateAbility();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
